﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;

using Styx;
using Styx.Combat.CombatRoutine;
using Styx.Helpers;
using Styx.Logic;
using Styx.Logic.BehaviorTree;
using Styx.Logic.Combat;
using Styx.Logic.Pathing;
using Styx.Logic.POI;
using Styx.WoWInternals.WoWObjects;
using TreeSharp;
using Action = TreeSharp.Action;
using Sequence = TreeSharp.Sequence;
using Styx.WoWInternals;


namespace Healz
{
    public class Healz : BotBase
    {
        #region Overrides of BotBase

        public static Config cSettings;
        public Healz()
        {
            FormSettings = new fSettings();
            cSettings = new Config();
            Druid.Main.cSettings = new Druid.Config();
        }

        public override void Initialize()
        {
            Utils.Write("Version: {0}", version.ToString());
            Utils.Write("http://www.thebuddyforum.com/honorbuddy-forum/classes/druid/42546-healz-stand-alone-healing-bot.html");
        }

        private Composite _root;
        public override Composite Root
        {
            get { return _root ?? (_root = new PrioritySelector( CreateCombatBehavior())); }
        }

        public Version version = new Version(1, 0, 0, 1);

        public override string Name
        {
            get { return "Healz"; }
        }

        public override PulseFlags PulseFlags
        {
            get { return PulseFlags.All; }
        }

        public override void Start()
        {
            StyxSettings.Instance.LogoutForInactivity = false;
            Utils.Write("Starting");

            if (StyxWoW.Me.SpecType != SpecType.Healer)
            {
                Utils.Write("Please Select a healing class");
                return;
            }
        }

        public static fSettings FormSettings;
        public override Form ConfigurationForm
        {
            get
            {
                return FormSettings;
            }
        }

        public override void Stop()
        {
            StyxSettings.Instance.LogoutForInactivity = true;
            Utils.Write("Stopping");
        }


        // "create a combat behavior" well were not using combat so
        internal static Composite CreateCombatBehavior()
        {
            return new PrioritySelector();
        }


        #endregion


        public override void Pulse()
        {
            // Bot is not enabled.
            if (!Utils.IsBotEnabled) return;
            if (StyxWoW.Me.SpecType != SpecType.Healer) return;

            switch (ObjectManager.Me.Class)
            {
                case WoWClass.Druid:
                    // Pulse Druid
                    Druid.Main.Pulse(0);
                    break;
                case WoWClass.Paladin:
                    break;
                case WoWClass.Priest:
                    break;
                case WoWClass.Shaman:
                    break;
                default:
                    break;
            }
        }
    }
}
